package cn.smile.admin;

import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;

import cn.smile.service.admin.DatabaseBakService;

import javax.annotation.Resource;

/**
 * 备份数据库定时器
 *
 * @author Administrator
 */
@Slf4j
@Configuration
@EnableScheduling
public class BackUpSchedule {

    @Resource
    private DatabaseBakService databaseBakService;

    @Scheduled(cron = "0 0 1 * * ?")//每天凌晨一点0分0秒执行备份任务
    public void backUpDatabase() {
        log.info("开始执行定时备份数据库任务！");
        databaseBakService.backup();
    }
}
